
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>CRYPT · Gitbook Use</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="mingyue">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-flexible-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../FLASH/simYC3122FLASH验证规范.html" />
    
    
    <link rel="prev" href="../ADC/simYC3122ADC验证规范.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../ADC/simYC3122ADC验证规范.html">
            
                <a href="../ADC/simYC3122ADC验证规范.html">
            
                    
                    ADC
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.1.2" data-path="simYC3122_CRYPT验证规范.html">
            
                <a href="simYC3122_CRYPT验证规范.html">
            
                    
                    CRYPT
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3" data-path="../FLASH/simYC3122FLASH验证规范.html">
            
                <a href="../FLASH/simYC3122FLASH验证规范.html">
            
                    
                    FLASH
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1" data-path="../FT/simYC3122FT.html">
            
                <a href="../FT/simYC3122FT.html">
            
                    
                    FT
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >CRYPT</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x7B97;&#x6CD5;&#x6D4B;&#x8BD5;"><b>1. </b>&#x7B97;&#x6CD5;&#x6D4B;&#x8BD5;</a></li><ul><li><span class="title-icon "></span><a href="#11-sha&#x7B97;&#x6CD5;&#x9A8C;&#x8BC1;&#x6D4B;&#x8BD5;"><b>1.1. </b>1.1 SHA&#x7B97;&#x6CD5;&#x9A8C;&#x8BC1;&#x6D4B;&#x8BD5;</a></li><ul><li><span class="title-icon "></span><a href="#111&#x6D4B;&#x8BD5;&#x5BF9;&#x8C61;"><b>1.1.1. </b>1.1.1&#x6D4B;&#x8BD5;&#x5BF9;&#x8C61;</a></li><li><span class="title-icon "></span><a href="#112&#x6D4B;&#x8BD5;&#x76EE;&#x7684;"><b>1.1.2. </b>1.1.2&#x6D4B;&#x8BD5;&#x76EE;&#x7684;</a></li><li><span class="title-icon "></span><a href="#113-&#x6D4B;&#x8BD5;&#x6761;&#x4EF6;"><b>1.1.3. </b>1.1.3 &#x6D4B;&#x8BD5;&#x6761;&#x4EF6;</a></li><li><span class="title-icon "></span><a href="#114-&#x6D4B;&#x8BD5;&#x73AF;&#x5883;"><b>1.1.4. </b>1.1.4 &#x6D4B;&#x8BD5;&#x73AF;&#x5883;</a></li><li><span class="title-icon "></span><a href="#115-&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;"><b>1.1.5. </b>1.1.5 &#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#116-&#x6D4B;&#x8BD5;&#x51FD;&#x6570;&#x63A5;&#x53E3;"><b>1.1.6. </b>1.1.6 &#x6D4B;&#x8BD5;&#x51FD;&#x6570;&#x63A5;&#x53E3;</a></li><li><span class="title-icon "></span><a href="#117-&#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x53CA;&#x8BB0;&#x5F55;"><b>1.1.7. </b>1.1.7 &#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x53CA;&#x8BB0;&#x5F55;</a></li><li><span class="title-icon "></span><a href="#118-&#x6D4B;&#x8BD5;&#x5C0F;&#x7ED3;"><b>1.1.8. </b>1.1.8 &#x6D4B;&#x8BD5;&#x5C0F;&#x7ED3;</a></li><li><span class="title-icon "></span><a href="#119-&#x6D4B;&#x8BD5;&#x76F8;&#x5173;&#x9644;&#x4EF6;"><b>1.1.9. </b>1.1.9 &#x6D4B;&#x8BD5;&#x76F8;&#x5173;&#x9644;&#x4EF6;</a></li></ul></ul></ul></div><a href="#&#x7B97;&#x6CD5;&#x6D4B;&#x8BD5;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x7B97;&#x6CD5;&#x6D4B;&#x8BD5;"><a name="&#x7B97;&#x6CD5;&#x6D4B;&#x8BD5;" class="anchor-navigation-ex-anchor" href="#&#x7B97;&#x6CD5;&#x6D4B;&#x8BD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x7B97;&#x6CD5;&#x6D4B;&#x8BD5;</h1>
<h2 id="11-sha&#x7B97;&#x6CD5;&#x9A8C;&#x8BC1;&#x6D4B;&#x8BD5;"><a name="11-sha&#x7B97;&#x6CD5;&#x9A8C;&#x8BC1;&#x6D4B;&#x8BD5;" class="anchor-navigation-ex-anchor" href="#11-sha&#x7B97;&#x6CD5;&#x9A8C;&#x8BC1;&#x6D4B;&#x8BD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. 1.1 SHA&#x7B97;&#x6CD5;&#x9A8C;&#x8BC1;&#x6D4B;&#x8BD5;</h2>
<h3 id="111&#x6D4B;&#x8BD5;&#x5BF9;&#x8C61;"><a name="111&#x6D4B;&#x8BD5;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#111&#x6D4B;&#x8BD5;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. 1.1.1&#x6D4B;&#x8BD5;&#x5BF9;&#x8C61;</h3>
<p>3122AB  9#EVB&#x677F;</p>
<h3 id="112&#x6D4B;&#x8BD5;&#x76EE;&#x7684;"><a name="112&#x6D4B;&#x8BD5;&#x76EE;&#x7684;" class="anchor-navigation-ex-anchor" href="#112&#x6D4B;&#x8BD5;&#x76EE;&#x7684;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.2. 1.1.2&#x6D4B;&#x8BD5;&#x76EE;&#x7684;</h3>
<ol>
<li>&#x6D4B;&#x8BD5;3122AB SHA&#x7B97;&#x6CD5;sha&#x5927;&#x6570;&#x636E;&#x8BA1;&#x7B97;&#x7684;&#x6B63;&#x786E;&#x6027;</li>
<li>sha&#x5927;&#x6570;&#x636E;&#x53EF;&#x63D2;&#x5165;&#x4E2D;&#x95F4;&#x503C;&#x8FD0;&#x7B97;&#xFF0C;&#x53EF;&#x540C;&#x65F6;&#x8FD0;&#x7B97;&#x591A;&#x7EC4;&#x6570;&#x636E;</li>
</ol>
<h3 id="113-&#x6D4B;&#x8BD5;&#x6761;&#x4EF6;"><a name="113-&#x6D4B;&#x8BD5;&#x6761;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#113-&#x6D4B;&#x8BD5;&#x6761;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.3. 1.1.3 &#x6D4B;&#x8BD5;&#x6761;&#x4EF6;</h3>
<p>1&#xFF09;&#x6D4B;&#x8BD5;&#x73AF;&#x5883;&#xFF1A;</p>
<p>&#x7535;&#x538B;&#xFF1A;</p>
<ul>
<li>USB 5V</li>
</ul>
<h3 id="114-&#x6D4B;&#x8BD5;&#x73AF;&#x5883;"><a name="114-&#x6D4B;&#x8BD5;&#x73AF;&#x5883;" class="anchor-navigation-ex-anchor" href="#114-&#x6D4B;&#x8BD5;&#x73AF;&#x5883;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.4. 1.1.4 &#x6D4B;&#x8BD5;&#x73AF;&#x5883;</h3>
<p><img src="media/8203d96cc345c2333a28d0a157d5dcd6.png" alt=""></p>
<h3 id="115-&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;"><a name="115-&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#115-&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.5. 1.1.5 &#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;</h3>
<p><strong>&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x5927;&#x6570;&#x636E;&#x8FD0;&#x7B97;</strong>&#xFF1A;</p>
<ol>
<li>&#x4E0A;&#x7535;&#x590D;&#x4F4D;</li>
<li>&#x521D;&#x59CB;&#x5316;&#x9700;&#x8981;&#x53C2;&#x4E0E;&#x54C8;&#x5E0C;&#x8FD0;&#x7B97;&#x7684;&#x503C;</li>
<li>&#x4F7F;&#x7528;&#x5728;&#x7EBF;&#x5DE5;&#x5177;<a href="https://i.goto327.top/CryptTools/SymmCrypt.aspx" target="_blank">&#x5BF9;&#x79F0;&#x52A0;&#x89E3;&#x5BC6;&#x7B97;&#x6CD5; (goto327.top)</a>&#x8BA1;&#x7B97;&#x51FA;&#x7ED3;&#x679C;&#xFF0C;&#x5E76;&#x586B;&#x5165;buf&#x4E2D;</li>
<li>3122AB&#x8FDB;&#x884C;&#x54C8;&#x5E0C;&#x8FD0;&#x7B97;</li>
<li>&#x5C06;&#x7B97;&#x7684;&#x7ED3;&#x679C;&#x4E0E;&#x5728;&#x7EBF;&#x5DE5;&#x5177;&#x7B97;&#x51FA;&#x6765;&#x7684;&#x7ED3;&#x679C;&#x8FDB;&#x884C;&#x6BD4;&#x8F83;&#xFF0C;&#x5982;&#x679C;&#x4E00;&#x81F4;&#xFF0C;&#x5219;&#x8BA4;&#x4E3A;3122AB&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x6B63;&#x786E;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x4E00;&#x81F4;&#xFF0C;&#x5219;&#x8BA4;&#x4E3A;3122AB&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x9519;&#x8BEF;</li>
</ol>
<p><strong>&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x591A;&#x7EC4;&#x540C;&#x65F6;&#x8FD0;&#x7B97;</strong>&#xFF1A;</p>
<ol>
<li>&#x4E0A;&#x7535;&#x590D;&#x4F4D;</li>
<li>&#x521D;&#x59CB;&#x5316;&#x9700;&#x8981;&#x53C2;&#x4E0E;&#x54C8;&#x5E0C;&#x8FD0;&#x7B97;&#x7684;&#x503C;</li>
<li>&#x5C06;&#x4E24;&#x7EC4;&#x6570;&#x636E;&#x62C6;&#x6210;&#x591A;&#x4EFD;</li>
<li>&#x4EE5;&#x7B2C;&#x4E00;&#x7EC4;&#x7B2C;&#x4E00;&#x4EFD;&#x6570;&#x636E;&#xFF0C;&#x7B2C;&#x4E8C;&#x7EC4;&#x7B2C;&#x4E00;&#x4EFD;&#x6570;&#x636E;&#xFF1B;&#x7B2C;&#x4E00;&#x7EC4;&#x7B2C;&#x4E8C;&#x4EFD;&#x6570;&#x636E;&#xFF0C;&#x7B2C;&#x4E8C;&#x7EC4;&#x7B2C;&#x4E8C;&#x4EFD;&#x6570;&#x636E;&#xFF1B;&#x4EE5;&#x6B64;&#x7C7B;&#x63A8;&#x5199;&#x5165;</li>
<li>&#x7B2C;&#x4E00;&#x7EC4;&#x6700;&#x540E;&#x4E00;&#x5305;&#xFF0C;&#x5E76;&#x83B7;&#x53D6;&#x54C8;&#x5E0C;&#x7ED3;&#x679C;&#xFF1B;&#x7B2C;&#x4E8C;&#x7EC4;&#x6700;&#x540E;&#x4E00;&#x5305;&#xFF0C;&#x5E76;&#x83B7;&#x53D6;&#x54C8;&#x5E0C;&#x7ED3;&#x679C;</li>
<li>&#x5C06;&#x4E00;&#x7EC4;&#x6570;&#x636E;&#x4E0E;&#x7B2C;&#x4E8C;&#x7EC4;&#x6570;&#x636E;&#x5355;&#x72EC;&#x76F4;&#x63A5;&#x4E00;&#x6B21;&#x6027;&#x8FDB;&#x884C;&#x54C8;&#x5E0C;&#x8FD0;&#x7B97;</li>
<li>&#x6BD4;&#x8F83;&#x5206;&#x6210;&#x591A;&#x4EFD;&#x8FD0;&#x7B97;&#x548C;&#x4E00;&#x6B21;&#x6027;&#x7684;&#x7ED3;&#x679C;&#x8FDB;&#x884C;&#x6BD4;&#x8F83;&#xFF0C;&#x5982;&#x679C;&#x4E00;&#x81F4;&#xFF0C;&#x5219;&#x8BA4;&#x4E3A;&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x591A;&#x7EC4;&#x540C;&#x65F6;&#x8FD0;&#x7B97;&#x6B63;&#x786E;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x4E00;&#x81F4;&#xFF0C;&#x5219;&#x8BA4;&#x4E3A;3122AB&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x591A;&#x7EC4;&#x540C;&#x65F6;&#x8FD0;&#x7B97;&#x9519;&#x8BEF;</li>
</ol>
<h3 id="116-&#x6D4B;&#x8BD5;&#x51FD;&#x6570;&#x63A5;&#x53E3;"><a name="116-&#x6D4B;&#x8BD5;&#x51FD;&#x6570;&#x63A5;&#x53E3;" class="anchor-navigation-ex-anchor" href="#116-&#x6D4B;&#x8BD5;&#x51FD;&#x6570;&#x63A5;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.6. 1.1.6 &#x6D4B;&#x8BD5;&#x51FD;&#x6570;&#x63A5;&#x53E3;</h3>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">UART_Configuration</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span></span>;
<span class="hljs-comment">/*sha&#x5927;&#x6570;&#x636E;&#x8BA1;&#x7B97;*/</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">test_sha</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span></span>;
<span class="hljs-comment">/*sha&#x5927;&#x6570;&#x636E;&#x53EF;&#x63D2;&#x5165;&#x4E2D;&#x95F4;&#x503C;&#x8FD0;&#x7B97;&#xFF0C;&#x53EF;&#x540C;&#x65F6;&#x8FD0;&#x7B97;&#x591A;&#x7EC4;&#x6570;&#x636E;*/</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">test_sha_sub</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span></span>;
<span class="hljs-comment">/*&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6570;&#x7EC4;*/</span>
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">bn_read_string_to_bytes</span><span class="hljs-params">(uint8_t *r, uint32_t len, <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *s)</span></span>;

<span class="hljs-comment">/**
 * @method main
 * @brief  Main program
 * @param  None
 * @retval None
 */</span>
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span>
</span>{
    Board_Init();

    MyPrintf(<span class="hljs-string">&quot;Yichip Yc3122 SHA test Demo V1.0.\r\n&quot;</span>);

    test_sha();

    test_sha_sub();

    <span class="hljs-keyword">while</span> (<span class="hljs-number">1</span>)
    {

    }
}

<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">test_sha</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span>
</span>{
    <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *cc1_160 = <span class="hljs-string">&quot;39F37D135FA66858516859BEF7E32F6C40D23640&quot;</span>;
    <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *cc1_224 = <span class="hljs-string">&quot;CBAE2F3E2A35AD314C8433509129F1B9AFC902E2BE144AF565CEF4EB&quot;</span>;
    <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *cc1_256 = <span class="hljs-string">&quot;346A578A87CFFC251AE7B0FE9ED08607C3537B691CFE7F521F6AD7D5AF015D90&quot;</span>;
    <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *cc1_384 = <span class="hljs-string">&quot;FBEBF75AD47A69F30729A9C2620904AFBD1BBCC237645E0CCA474AAD36320ED008FC5D9E2A2208C5FDF37F967A0BAEE9&quot;</span>;
    <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *cc1_512 = <span class="hljs-string">&quot;4E5B77FEF46B48EFD195BB5478B82CB70F203BF5600345B9B7C00567444C029E2E85143A321C7E88C558F564B2D856FB4CFB6979F2D37A27A5531E469809AC6A&quot;</span>;

<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> inputlen        (1024 * 10)</span>
    <span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>;

    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> c_512[inputlen + <span class="hljs-number">1</span>] = {<span class="hljs-number">0</span>};

    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> c1_160[<span class="hljs-number">160</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> c1_224[<span class="hljs-number">224</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> c1_256[<span class="hljs-number">256</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> c1_384[<span class="hljs-number">384</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> c1_512[<span class="hljs-number">512</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};

    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> exp_c1_160[<span class="hljs-number">160</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> exp_c1_224[<span class="hljs-number">224</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> exp_c1_256[<span class="hljs-number">256</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> exp_c1_384[<span class="hljs-number">384</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> exp_c1_512[<span class="hljs-number">512</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};

    MyPrintf(<span class="hljs-string">&quot;\n*************SHA Test In*************\n&quot;</span>);
    <span class="hljs-comment">//&#x5B57;&#x7B26;&#x8F6C;&#x6362;&#x6210;&#x6570;&#x7EC4;&#x5B58;&#x50A8;</span>
    bn_read_string_to_bytes(exp_c1_160, <span class="hljs-keyword">sizeof</span>(exp_c1_160), cc1_160);
    bn_read_string_to_bytes(exp_c1_224, <span class="hljs-keyword">sizeof</span>(exp_c1_224), cc1_224);
    bn_read_string_to_bytes(exp_c1_256, <span class="hljs-keyword">sizeof</span>(exp_c1_256), cc1_256);
    bn_read_string_to_bytes(exp_c1_384, <span class="hljs-keyword">sizeof</span>(exp_c1_384), cc1_384);
    bn_read_string_to_bytes(exp_c1_512, <span class="hljs-keyword">sizeof</span>(exp_c1_512), cc1_512);

    <span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i &lt; inputlen; i++)
        c_512[inputlen - i - <span class="hljs-number">1</span>] = i;

    <span class="hljs-built_in">memset</span>(c1_160, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(c1_160));
    <span class="hljs-built_in">memset</span>(c1_224, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(c1_224));
    <span class="hljs-built_in">memset</span>(c1_256, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(c1_256));
    <span class="hljs-built_in">memset</span>(c1_384, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(c1_384));
    <span class="hljs-built_in">memset</span>(c1_512, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(c1_512));
    SHA(SHATYPE_1, c1_160, c_512, inputlen);    <span class="hljs-comment">//&#x8BA1;&#x7B97;&#x51FA;&#x7684;HASH&#x503C;&#x4E0E;&#x5DF2;&#x5B9A;&#x4E49;&#x7684;&#x7ED3;&#x679C;&#x6BD4;&#x8F83;</span>
    printv(c1_160, <span class="hljs-keyword">sizeof</span>(c1_160), <span class="hljs-string">&quot;c1_160&quot;</span>);
    printv(exp_c1_160, <span class="hljs-keyword">sizeof</span>(exp_c1_160), <span class="hljs-string">&quot;exp_c1_160&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;\nSHA c1_160 test:%2x\n&quot;</span>, <span class="hljs-number">0</span> == (<span class="hljs-built_in">memcmp</span>(c1_160, exp_c1_160, <span class="hljs-keyword">sizeof</span>(exp_c1_160))));
    SHA(SHATYPE_224, c1_224, c_512, inputlen);
    printv(c1_224, <span class="hljs-keyword">sizeof</span>(c1_224), <span class="hljs-string">&quot;c1_224&quot;</span>);
    printv(exp_c1_224, <span class="hljs-keyword">sizeof</span>(exp_c1_224), <span class="hljs-string">&quot;exp_c1_224&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;\nSHA c1_224 test:%2x\n&quot;</span>, <span class="hljs-number">0</span> == (<span class="hljs-built_in">memcmp</span>(c1_224, exp_c1_224, <span class="hljs-keyword">sizeof</span>(exp_c1_224))));
    SHA(SHATYPE_256, c1_256, c_512, inputlen);
    printv(c1_256, <span class="hljs-keyword">sizeof</span>(c1_256), <span class="hljs-string">&quot;c1_256&quot;</span>);
    printv(exp_c1_256, <span class="hljs-keyword">sizeof</span>(exp_c1_256), <span class="hljs-string">&quot;exp_c1_256&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;\nSHA c1_256 test:%2x\n&quot;</span>, <span class="hljs-number">0</span> == (<span class="hljs-built_in">memcmp</span>(c1_256, exp_c1_256, <span class="hljs-keyword">sizeof</span>(exp_c1_256))));
    SHA(SHATYPE_384, c1_384, c_512, inputlen);
    printv(c1_384, <span class="hljs-keyword">sizeof</span>(c1_384), <span class="hljs-string">&quot;c1_384&quot;</span>);
    printv(exp_c1_384, <span class="hljs-keyword">sizeof</span>(exp_c1_384), <span class="hljs-string">&quot;exp_c1_384&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;\nSHA c1_384 test:%2x\n&quot;</span>, <span class="hljs-number">0</span> == (<span class="hljs-built_in">memcmp</span>(c1_384, exp_c1_384, <span class="hljs-keyword">sizeof</span>(exp_c1_384))));
    SHA(SHATYPE_512, c1_512, c_512, inputlen);
    printv(c1_512, <span class="hljs-keyword">sizeof</span>(c1_512), <span class="hljs-string">&quot;c1_512&quot;</span>);
    printv(exp_c1_512, <span class="hljs-keyword">sizeof</span>(exp_c1_512), <span class="hljs-string">&quot;exp_c1_512&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;\nSHA c1_512 test:%2x\n&quot;</span>, <span class="hljs-number">0</span> == (<span class="hljs-built_in">memcmp</span>(c1_512, exp_c1_512, <span class="hljs-keyword">sizeof</span>(exp_c1_512))));
}

<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">test_sha_sub</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span>
</span>{
    SHA_CTX  c1, c2;
    <span class="hljs-keyword">uint8_t</span> Test_tmp1[data_len];
    <span class="hljs-keyword">uint8_t</span> Test_tmp2[data_len];
    <span class="hljs-keyword">uint8_t</span> Hash_sub_1[<span class="hljs-number">512</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">uint8_t</span> Hash_sub_2[<span class="hljs-number">512</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">uint8_t</span> Hash_1[<span class="hljs-number">512</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">uint8_t</span> Hash_2[<span class="hljs-number">512</span> / <span class="hljs-number">8</span>] = {<span class="hljs-number">0</span>};
    <span class="hljs-keyword">uint16_t</span> i, j;
    <span class="hljs-keyword">uint8_t</span> len;
    <span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i &lt; data_len; i++)
    {
        Test_tmp1[i] = GetTRNGData_8bit();  <span class="hljs-comment">//&#x901A;&#x8FC7;&#x968F;&#x673A;&#x6570;&#x53D6;&#x6570;&#x636E;</span>
        Test_tmp2[i] = GetTRNGData_8bit();
    }
    MyPrintf(<span class="hljs-string">&quot;/******************/\n&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;return 1 express test ture, 0 express test false\n&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;return mode = 0 express test mode is SHATYPE_1\n&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;return mode = 1 express test mode is SHATYPE_224\n&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;return mode = 2 express test mode is SHATYPE_256\n&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;return mode = 3 express test mode is SHATYPE_384\n&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;return mode = 4 express test mode is SHATYPE_512\n&quot;</span>);
    MyPrintf(<span class="hljs-string">&quot;/******************/\n&quot;</span>);
    <span class="hljs-keyword">for</span> (j = <span class="hljs-number">0</span>; j &lt; <span class="hljs-number">5</span>; j++) <span class="hljs-comment">//&#x8BA1;&#x7B97;&#x4E24;&#x7EC4;SHA&#x6570;&#x636E;&#xFF0C;&#x4E24;&#x7EC4;&#x6570;&#x636E;&#x6570;&#x636E;&#x53EF;&#x5206;&#x5F00;&#x5206;&#x6BB5;&#x8FD0;&#x7B97;</span>
    {
        SHA_Init(&amp;c1, (SHA_ModeTypeDef)j);
        SHA_Init(&amp;c2, (SHA_ModeTypeDef)j);
        <span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i &lt; data_len; i += c1.SHA_CBlock)
        {
            <span class="hljs-keyword">if</span> (<span class="hljs-number">0</span> &lt;= data_len - i &amp;&amp; data_len - i &lt; c1.SHA_CBlock)
                len = data_len - i;
            <span class="hljs-keyword">else</span>
                len = c1.SHA_CBlock;
            SHA_Update(&amp;c1, Test_tmp1 + i, len); <span class="hljs-comment">//&#x63A5;&#x53E3;&#x540C;&#x65F6;&#x8FD0;&#x7B97;&#x4E24;&#x7EC4;&#x6570;&#x636E;</span>
            SHA_Update(&amp;c2, Test_tmp2 + i, len);
        }
        <span class="hljs-built_in">memset</span>(Hash_sub_1, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(Hash_sub_1));
        <span class="hljs-built_in">memset</span>(Hash_sub_2, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(Hash_sub_2));
        SHA_Final(&amp;c1, Hash_sub_1);
        SHA_Final(&amp;c2, Hash_sub_2);
        <span class="hljs-built_in">memset</span>(Hash_1, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(Hash_1));
        <span class="hljs-built_in">memset</span>(Hash_2, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(Hash_2));
        SHA((SHA_ModeTypeDef)j, Hash_1, Test_tmp1, data_len); <span class="hljs-comment">//&#x5355;&#x72EC;&#x8FD0;&#x7B97;SHA&#x6570;&#x636E;</span>
        SHA((SHA_ModeTypeDef)j, Hash_2, Test_tmp2, data_len);
        MyPrintf(<span class="hljs-string">&quot;Hash_sub_1 test = %d,test mode = %d\n&quot;</span>, (!<span class="hljs-built_in">memcmp</span>(Hash_sub_1, Hash_1, <span class="hljs-keyword">sizeof</span>(Hash_1))), j); <span class="hljs-comment">//&#x8F93;&#x51FA;&#x6BD4;&#x8F83;&#x7ED3;&#x679C;</span>
        MyPrintf(<span class="hljs-string">&quot;Hash_sub_1 test = %d,test mode = %d\n&quot;</span>, (!<span class="hljs-built_in">memcmp</span>(Hash_sub_2, Hash_2, <span class="hljs-keyword">sizeof</span>(Hash_1))), j);
    }
}
</code></pre>
<h3 id="117-&#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x53CA;&#x8BB0;&#x5F55;"><a name="117-&#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x53CA;&#x8BB0;&#x5F55;" class="anchor-navigation-ex-anchor" href="#117-&#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x53CA;&#x8BB0;&#x5F55;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.7. 1.1.7 &#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x53CA;&#x8BB0;&#x5F55;</h3>
<p><strong>&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x5927;&#x6570;&#x636E;&#x8FD0;&#x7B97;&#x8BB0;&#x5F55;&#xFF1A;</strong></p>
<p><img src="media/ec75922ce2b5f1f10631324ae991fc9.png" alt="ec75922ce2b5f1f10631324ae991fc9"></p>
<p><strong>&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x591A;&#x7EC4;&#x540C;&#x65F6;&#x8FD0;&#x7B97;&#x8BB0;&#x5F55;&#xFF1A;</strong></p>
<p><img src="media/594747d414f76594c3d0adbb9d3324f.png" alt="594747d414f76594c3d0adbb9d3324f"></p>
<h3 id="118-&#x6D4B;&#x8BD5;&#x5C0F;&#x7ED3;"><a name="118-&#x6D4B;&#x8BD5;&#x5C0F;&#x7ED3;" class="anchor-navigation-ex-anchor" href="#118-&#x6D4B;&#x8BD5;&#x5C0F;&#x7ED3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.8. 1.1.8 &#x6D4B;&#x8BD5;&#x5C0F;&#x7ED3;</h3>
<p>&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x5927;&#x6570;&#x636E;&#x8FD0;&#x7B97;&#x7ED3;&#x679C;&#x6B63;&#x786E;&#xFF0C;&#x54C8;&#x5E0C;&#x7B97;&#x6CD5;&#x591A;&#x7EC4;&#x540C;&#x65F6;&#x8FD0;&#x7B97;&#x6B63;&#x786E;</p>
<h3 id="119-&#x6D4B;&#x8BD5;&#x76F8;&#x5173;&#x9644;&#x4EF6;"><a name="119-&#x6D4B;&#x8BD5;&#x76F8;&#x5173;&#x9644;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#119-&#x6D4B;&#x8BD5;&#x76F8;&#x5173;&#x9644;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.9. 1.1.9 &#x6D4B;&#x8BD5;&#x76F8;&#x5173;&#x9644;&#x4EF6;</h3>
</body></html>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../ADC/simYC3122ADC验证规范.html" class="navigation navigation-prev " aria-label="Previous page: ADC">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../FLASH/simYC3122FLASH验证规范.html" class="navigation navigation-next " aria-label="Next page: FLASH">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"CRYPT","level":"1.1.2","depth":2,"next":{"title":"FLASH","level":"1.1.3","depth":2,"path":"FLASH/simYC3122FLASH验证规范.md","ref":"./FLASH/simYC3122FLASH验证规范.md","articles":[{"title":"FT","level":"1.1.3.1","depth":3,"path":"FT/simYC3122FT.md","ref":"./FT/simYC3122FT.md","articles":[]}]},"previous":{"title":"ADC","level":"1.1.1","depth":2,"path":"ADC/simYC3122ADC验证规范.md","ref":"./ADC/simYC3122ADC验证规范.md","articles":[]},"dir":"ltr"},"config":{"plugins":["anchor-navigation-ex","flexible-alerts","hide-element","chapter-fold","-sharing","sharing-plus","theme-comscore","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"chapter-fold":{},"livereload":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"showLevel":true,"associatedWithSummary":true,"mode":"float","showGoTop":true,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"theme-comscore":{},"flexible-alerts":{"style":"callout","note":{"label":"Note","icon":"fa fa-info-circle","className":"info"},"tip":{"label":"Tip","icon":"fa fa-lightbulb-o","className":"tip"},"warning":{"label":"Warning","icon":"fa fa-exclamation-triangle","className":"warning"},"danger":{"label":"Attention","icon":"fa fa-ban","className":"danger"}},"sharing":{"qq":true,"douban":true,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"mingyue","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Gitbook Use","language":"zh-hans","gitbook":"*","description":"记录Gitbook的配置和一些插件的使用","theme-default":{"showLevel":true}},"file":{"path":"CRYPT/simYC3122_CRYPT验证规范.md","mtime":"2022-01-24T10:00:46.642Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-01-30T07:46:55.331Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

